I've trying to display object headings in a richText box in a dialog, but I can't seem to be able to specify different fonts for the richtext box. It always seems to use the default font. I can retrieve the font information for the Object Heading using this form of the richText function: string s = richText(o."Object Heading", true) However, if I try to display this in a DBE, it just shows the object heading. I've also tried manually setting the font table, but this does not work. As anyone got an ideas or examples of using different fonts in a richtext DBE?
TheNybbler - Sun Jan 24 13:48:52 EST 2016 |
Re: Using different fonts in a richText DBE element The following code demonstrates what happens when you paste some Rich Text into the text box. It displays correctly, but if you then attempt to rewrite the same content back into the text box, the font information is lost:
Object o = first current Module;
DB xDB = centered("Headings in a richText DBE")
DBE xRichText = richText(xDB,"richText DBE:", "Paste something in", 360, 250, false)
DBE xLabel = label(xDB , "Object:");
void cbNext(DBE dbe)
{
bool found = false
while (!found && o != last(current Module))
{
string headNum = number(o);
string txt = "" identifier(o) ": " headNum " " o."Object Heading" "";
set(xLabel, txt);
if (!matches("-", headNum))
{
found = true;
int absNum = obj."Absolute Number";
string richTxt = richText(o."Object Heading", true);
set(xRichText, richTxt);
print(richTxt "\n\n");
}
o = next(o);
}
}
void cbPrint(DBE dbe)
{
string s = get(xRichText);
print s "\n\n";
infoBox("Clear RichTextBox");
set(xRichText, "");
infoBox("Update RichTextBox");
set(xRichText, s);
}
DBE xNext = button(xDB, "Next", cbNext, true, 70);
DBE xPrint = button(xDB, "Print", cbPrint, true, 70);
realize(xDB)
useRTFColour(xRichText,true)
Buffer textBuffer = create;
for obj in current Module do
{
string headTxt = obj."Object Heading";
string headNum = number(obj);
if (!matches("-", headNum))
{
int absNum = obj."Absolute Number";
textBuffer += richText(o."Object Heading", true)
textBuffer += "\\par ";
}
}
show(xDB)
|